//
//  User.swift
//  xiaoqiao
//
//  Created by 冷子豪 on 2017/8/1.
//  Copyright © 2017年 冷子豪. All rights reserved.
//

import Foundation

var user = User()

class User{
    /// id
    var id:Int?
    /// 昵称
    var nickname:String?
    /// 密码
    var password:String?
    /// 真实姓名
    var realname:String?
    /// 性别
    var sex:String?
    /// phone(兼用做登录名)
    var phone:String?
    /// 省份
    var province:String?
    /// 城市
    var city:String?
    /// 区域
    var district:String?
    /// 邮箱
    var email:String?
    /// 持卡人姓名
    var cardHolder:String?
    /// 开户行
    var cardBank:String?
    /// 银行卡号
    var cardNumber:String?
    /// 生日
    var birthday:Date?
    /// 头像
    var icon:String?
    /// 等级
    var grade:String?
    /// 邀请二维码地址
    var inviteLink:String?
    /// 状态
    var status:String?
    /// 创建时间
    var createtime:Date?
    /// 更新时间
    var updatetime:Date?
    
    
    /// 重写的构造方法
    init() {
//        super.init()
    }
    
    /// 自定义构造函数,会覆盖init()函数
    ///
    /// - Parameter dic:
    init(dic : [String : Any]) {
        id = dic["id"] as? Int
        nickname = dic["nickname"] as? String
        password = dic["password"] as? String
        realname = dic["realname"] as? String
        sex = dic["sex"] as? String
        phone = dic["phone"] as? String
        province = dic["province"] as? String
        city = dic["city"] as? String
        district = dic["district"] as? String
        email = dic["email"] as? String
        cardHolder = dic["cardHolder"] as? String
        cardBank = dic["cardBank"] as? String
        cardNumber = dic["cardNumber"] as? String
        //        生日
        birthday = NSDate(timeIntervalSince1970: TimeInterval(0)) as Date
        icon = dic["icon"] as? String
        grade = dic["grade"] as? String
        status = dic["status"] as? String
        inviteLink = dic["invitelink"] as? String
        //        创建、更新时间
        let createStamp = (dic["createtime"] as? Int)!
        let updateStamp = (dic["updatetime"] as? Int)!
        createtime = NSDate(timeIntervalSince1970: TimeInterval(createStamp/1000)) as Date
        updatetime = NSDate(timeIntervalSince1970: TimeInterval(updateStamp/1000)) as Date
        //
        //        let dformatter = DateFormatter()
        //        dformatter.dateFormat = "yyyy年MM月dd日"
        //        print("对应的日期时间：\(dformatter.string(from: createtime!))")
//        super.init()
    }
}
